package com.dl.controller;

import com.dl.response.CommonResult;
import com.dl.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class AccountController {
    @Autowired
    private AccountService accountService;

    @RequestMapping("/account/decrease")
    public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        int result = accountService.decrease(userId,money);
        if(result>0){
            return CommonResult.createBySuccessMsg("账户扣减成功",null);
        }else{
            return CommonResult.createByErrorMsg("账户扣减失败！",null);
        }
    }
}
